<?php defined('SYSPATH') OR die('No direct access allowed.');

class Deal_Controller extends Template_Controller 
{
	public $template = 'deal';
	public $content = 'deal_content';

	public function __construct()
	{
		parent::__construct();
		$this->template->title = 'Welcome to Fitness!';
	}

	public function index()
	{
		url::redirect();
	}

	public function show($id)
	{
		$gym = ORM::factory('gym');
		$gym->get_gym($id);
		if ($gym->loaded)
		{
			$this->template->content->set("gym", $gym);
			$this->template->content->set("city_zone", $gym->get_city_zone($id));
			$this->template->content->set("city_name", $gym->get_city_name($id));
		}
		else
		{
			url::redirect('');
		}
	}

	public function get_product_price($product_id)
	{
		$product = ORM::factory('product');
		$product->get_product($product_id);
		if ($product->loaded)
		{
			exit($product->product_price);
		}
		exit(-1);
	}
}

